//
//  JWaitPayDetailButtomView.m
//  HeadIndustry
//
//  Created by jun on 2017/9/12.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JWaitPayDetailButtomView.h"

@implementation JWaitPayDetailButtomView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.opaque = NO;
     
    }
    return  self;
}

- (void)setUpViewType1 {
    CALayer *line3 = [CALayer layer];
    line3.backgroundColor = kRGBColor(150, 150, 150).CGColor;
    line3.frame = CGRectMake(0, 0, kWindowW, 0.5);
    [self.layer addSublayer:line3];
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame = CGRectMake(kWindowW - 15 - 40, 5, 40, 40);
    [btn1 setTitle:@"付款" forState:UIControlStateNormal];
    [btn1 setTitleColor:kRGBColor(98, 98, 98) forState:UIControlStateNormal];
    btn1.titleLabel.font = kFONT_TITLE(16);
    
    btn1.layer.cornerRadius = 5;
    btn1.layer.borderColor = kRGBColor(98, 98, 98).CGColor;
    btn1.layer.borderWidth = 1;
    btn1.tag = 1;
    [btn1 addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn1];
    
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn2.frame = CGRectMake( btn1.left - 10 - 75, 5, 75, 40);
    [btn2 setTitle:@"联系商家" forState:UIControlStateNormal];
    [btn2 setTitleColor:kRGBColor(98, 98, 98) forState:UIControlStateNormal];
    btn2.titleLabel.font = kFONT_TITLE(16);
    
    btn2.layer.cornerRadius = 5;
    btn2.layer.borderColor = kRGBColor(98, 98, 98).CGColor;
    btn2.layer.borderWidth = 1;
    btn2.tag = 2;
    [btn2 addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn2];
    
    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn3.frame = CGRectMake( btn2.left - 10 - 75, 5, 75, 40);
    [btn3 setTitle:@"取消订单" forState:UIControlStateNormal];
    [btn3 setTitleColor:kRGBColor(98, 98, 98) forState:UIControlStateNormal];
    btn3.titleLabel.font = kFONT_TITLE(16);
    
    btn3.layer.cornerRadius = 5;
    btn3.layer.borderColor = kRGBColor(98, 98, 98).CGColor;
    btn3.layer.borderWidth = 1;
    btn3.tag = 3;
    [btn3 addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn3];
}

- (void)setUpViewType2 {
    CALayer *line3 = [CALayer layer];
    line3.backgroundColor = kRGBColor(150, 150, 150).CGColor;
    line3.frame = CGRectMake(0, 0, kWindowW, 0.5);
    [self.layer addSublayer:line3];
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame = CGRectMake(kWindowW - 15 - 75, 5, 75, 40);
    [btn1 setTitle:@"联系商家" forState:UIControlStateNormal];
    [btn1 setTitleColor:kRGBColor(98, 98, 98) forState:UIControlStateNormal];
    btn1.titleLabel.font = kFONT_TITLE(16);
    
    btn1.layer.cornerRadius = 5;
    btn1.layer.borderColor = kRGBColor(98, 98, 98).CGColor;
    btn1.layer.borderWidth = 1;
    btn1.tag = 2;
    [btn1 addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn1];
    
    if (_ishave) {
        UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
        btn2.frame = CGRectMake( btn1.left - 10 - 75, 5, 75, 40);
        [btn2 setTitle:@"确认收货" forState:UIControlStateNormal];
        [btn2 setTitleColor:kRGBColor(98, 98, 98) forState:UIControlStateNormal];
        btn2.titleLabel.font = kFONT_TITLE(16);
        
        btn2.layer.cornerRadius = 5;
        btn2.layer.borderColor = kRGBColor(98, 98, 98).CGColor;
        btn2.layer.borderWidth = 1;
        btn2.tag = 4;
        [btn2 addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btn2];
    }
    
    
//    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
//    btn3.frame = CGRectMake( btn2.left - 10 - 75, 5, 75, 40);
//    [btn3 setTitle:@"取消订单" forState:UIControlStateNormal];
//    [btn3 setTitleColor:kRGBColor(98, 98, 98) forState:UIControlStateNormal];
//    btn3.titleLabel.font = kFONT_TITLE(16);
//    
//    btn3.layer.cornerRadius = 5;
//    btn3.layer.borderColor = kRGBColor(98, 98, 98).CGColor;
//    btn3.layer.borderWidth = 1;
//    btn3.tag = 3;
//    [btn3 addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:btn3];
}

- (void)payBtnClick:(UIButton *)btn
{
    if (_block) {
        _block(btn.tag);
    }
}

- (void)setIshave:(BOOL)ishave
{
    _ishave = ishave;
}

- (void)setSelType:(NSInteger)selType
{
    _selType = selType;
    if (_selType == 0) {
        [self setUpViewType1];
    }
    else
    {
        [self setUpViewType2];
    }
}

@end
